package com.xxx.mapper;

import com.xxx.pojo.Dish;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface DishMapper {


    @Insert("insert into dish values (#{name},#{typesName},#{price},#{id},#{img},#{describe},#{state},#{order},#{createTime},#{updateTime},#{createUser},#{updateUser},#{dele})")
    int addDish(Dish dish);

    @Select("select * from dish limit #{index},#{num} ;")
    @ResultMap("dishResultMap")
    List<Dish> selectAll(@Param("index") Integer index, @Param("num") Integer num);

    @Select("select * from dish where dish_id = #{id};")
    @ResultMap("dishResultMap")
    Dish selectById(Long id);

    @Update("update dish set dish_name = #{name}, types_name=#{typesName},price=#{price},dish_img=#{img},`describe`=#{describe},state=#{state},up_time=#{updateTime},update_user=#{updateUser} where dish_id=#{id};")
    int updateDish(Dish dish);

    @Delete("delete from dish where dish_id = #{id};")
    int deleteById(Long id);

    @Select("select count(*) from dish;")
    int selectCount();

    @Select("select * from dish where dish_name = #{dishName};")
    @ResultMap("dishResultMap")
    Dish selectByName(@Param("dishName") String dishName);
}
